<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>员工新增</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">物品名：</label>
                <div class="layui-input-block">
                    <input name="name" lay-verify="title" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">数量：</label>
                <div class="layui-input-block">
                    <input type="number" name="num" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">物品类型：</label>
                <div class="layui-input-block">
                    <select name="type">
                        <option value="饮品类">饮品类</option>
                        <option value="小吃类">小吃类</option>
                        <option value="床上用品">床上用品</option>
                        <option value="生活用品">生活用品</option>
                        <option value="消毒工具">消毒工具</option>
                        <option value="消防工具">消防工具</option>
                        <option value="急救物品">急救物品</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">负责人：</label>
                <div class="layui-input-block">
                    <input name="ename" lay-reqtext="谁负责的，一定要有记录" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">物品简介：</label>
                <div class="layui-input-block">
                    <input name="info" lay-reqtext="对物品进行描述" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="demo1">添加物品</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script src="lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="js/jquery-3.6.0.min.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form','laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , laydate = layui.laydate;
        //日期
        laydate.render({
            elem: '#date'
        });
        //监听提交
        form.on('submit(demo1)', function (data) {

            //ajax 调用接口
            $.post("/api/hgoods/save.do",data.field,function(res){
                if(res.code==200){
                    //新增成功
                    layer.msg('新增成功！');
                }else{
                    //新增失败
                    layer.msg('新增失败！');
                }
            });
            return false;
        });
    });
</script>
</body>
</html>